package com.foreknow.elm.service.impl;

import com.foreknow.elm.dao.FoodDao;
import com.foreknow.elm.dao.impl.FoodDaoImpl;
import com.foreknow.elm.po.Food;
import com.foreknow.elm.service.FoodService;
import com.foreknow.elm.util.DBUtil;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class FoodServiceImpl implements FoodService {
    /**
     * 根据商家编号查询所属食品信息
     * @param businessId
     * @return
     */
    @Override
    public List<Food> listFoodByBusinessId(Integer businessId) {
        List<Food> list = new ArrayList<>();
        FoodDao foodDao = new FoodDaoImpl();
            try {
                //数据库链接
                DBUtil.getConnection();
                list =foodDao.listFoodByBusinessId(businessId);
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
            // 关闭Connection
            DBUtil.close();
        }
        return list;
    }
}
